<?php

use yii\db\Migration;

/**
 * Handles the creation of table `page`.
 */
class m210120_135052_create_page_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('page', [
            'id' => $this->primaryKey(),
            'title' => $this->string(255)->notNull(),
            'alias' => $this->string(255)->notNull(),
            'description' => $this->string(255)->notNull(),
            'content' => $this->text(),
            'path' => $this->string(255),
            'depth' => $this->integer()->notNull(),
            'sort' => $this->integer()->notNull(),
        ]);

        $this->createIndex(
            'idx-page-path',
            'page',
            'path'
        );
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropIndex(
            'idx-page-path',
            'page'
        );
        $this->dropTable('page');
    }
}
